﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paringregkaardid_vastus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(ParingregkaardidVastus))]
    public class ParingregkaardidVastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParingregkaardidVastus clazz;
        
        public ParingregkaardidVastusSerializer(IParingregkaardidVastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("vastus");
            if (clazz.Vastus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "base64Binary");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.Vastus))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="vastus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Vastus = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("vastus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringregkaardid_vastus>vastus", Reader.LocalName);
            }
        }
    }
}
